Emit GdkDevice::changed when the slave device being used changes
authorCarlos Garnacho <carlosg@gnome.org>
Wed, 15 Dec 2010 01:34:42 +0000 (02:34 +0100)
committerCarlos Garnacho <carlosg@gnome.org>
Wed, 15 Dec 2010 02:17:58 +0000 (03:17 +0100)
When the slave device changes, the master takes the shape of the
new one, modifying its axes, this signal is more useful to catch
this situation than the n-axes property

gdk/gdkdevice.c
gdk/x11/gdkdevicemanager-xi2.c

index 4e9b3d24e8b53d8ba7c65771269e84dfecaccaf8..dc66f3bdddc70bd2d550865335915d9ba0c08852 100644 (file)
@@ -64,6 +64,14 @@ struct _GdkDevicePrivate
   GArray *axes;
 };
 
+enum {
+  CHANGED,
+  LAST_SIGNAL
+};
+
+static guint signals [LAST_SIGNAL] = { 0 };
+
+
 static void gdk_device_dispose      (GObject      *object);
 static void gdk_device_set_property (GObject      *object,
                                      guint         prop_id,
@@ -238,6 +246,26 @@ gdk_device_class_init (GdkDeviceClass *klass)
                                                       0, G_MAXUINT, 0,
                                                       G_PARAM_READABLE | G_PARAM_STATIC_STRINGS));
 
+  /**
+   * GdkDevice::changed:
+   * @device: the #GdkDevice that changed.
+   *
+   * The ::changed signal is emitted either when the #GdkDevice
+   * has changed the number of either axes or keys. For example
+   * In X this will normally happen when the slave device routing
+   * events through the master device changes (for example, user
+   * switches from the USB mouse to a tablet), in that case the
+   * master device will change to reflect the new slave device
+   * axes and keys.
+   */
+  signals[CHANGED] =
+    g_signal_new (g_intern_static_string ("changed"),
+                  G_TYPE_FROM_CLASS (object_class),
+                  G_SIGNAL_RUN_LAST,
+                  NULL, NULL, NULL,
+                  g_cclosure_marshal_VOID__VOID,
+                  G_TYPE_NONE, 0);
+
   g_type_class_add_private (object_class, sizeof (GdkDevicePrivate));
 }
 
index 1cc2fc2a27e393a205d01e8a3857ffee5edfd6d3..bdfeac9953426e07e18a862d63460cd77835e6ee 100644 (file)
@@ -499,6 +499,8 @@ handle_device_changed (GdkDeviceManagerXI2  *device_manager,
 
   _gdk_device_reset_axes (device);
   translate_device_classes (display, device, ev->classes, ev->num_classes);
+
+  g_signal_emit_by_name (G_OBJECT (device), "changed");
 }
 
 static GdkCrossingMode